import Vue from 'vue';
import Router from 'vue-router';
import Layout from '@/components/common/layout'
import auth from "@/utils/auth";

Vue.use(Router);

let constantRoutes = [
    {
        path: '/login',
        component: () => import('@/views/user/login')
    }, {
        path: '/404',
        component: resolve => require(['@/views/404'], resolve),
    }, {
        path: '*',
        redirect: '/'
    }
];

let menus = auth.getAccount().menus || []
constantRoutes.push({
    path: '/',
    component: Layout,
    meta: { title: '' },
    children: menus
})
const createRouter = () => new Router({
    mode: 'hash',
    base: '/work/',
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
})
const router = createRouter()
export default router
